﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr XMLNS:MSHelp = "http://msdn.microsoft.com/mshelp" xmlns:ddue = 
"http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink = 
"http://www.w3.org/1999/xlink" xmlns:tool = "http://www.microsoft.com/tooltip" 
XMLNS:[default] http://ddue.schemas.microsoft.com/authoring/2003/5 = 
"http://ddue.schemas.microsoft.com/authoring/2003/5"><HEAD><TITLE>WebNoAuth Sample</TITLE>
<META content="text/html; CHARSET=utf-8" http-equiv=Content-Type></META>
<META name=save content=history></META><LINK rel=stylesheet type=text/css 
href="../../../../CommonFiles/Classic.css"></LINK>

<META name=GENERATOR content="MSHTML 8.00.6001.18783"></HEAD>
<BODY>
<DIV id=header>
<TABLE id=topTable width="100%">
  <TBODY>
  <TR id=headerTableRow1>
    <TD align=left><SPAN id=runningHeaderText></SPAN></TD></TR>
  <TR id=headerTableRow2>
    <TD align=left><SPAN id=nsrTitle>WebNoAuth Sample</SPAN></TD></TR>
  <TR id=headerTableRow3>
    <TD></TD></TR></TBODY></TABLE>
</DIV>
<DIV id=mainSection>
<DIV id=mainBody>
<DIV id=allHistory class=saveHistory onload="loadAll()" 
onsave="saveAll()"></DIV>
<P>This sample demonstrates how to expose an HTTP service that does not require 
client user authentication.</P>
<H2 class=heading>Prerequisites</H2>
<DIV id=sectionSection0 class=section><content 
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
<P xmlns="">If you haven't already done so, read the release notes document that 
explains how to sign up for a Windows Azure account and how to 
configure your environment.</P></content></DIV>
<H2 class=heading>Service</H2>
<DIV id=sectionSection1 class=section><content 
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
<P xmlns="">The service in this sample creates a simple RSS feed and returns it 
using the .NET Framework RSS/Atom features and the extended 
"Web-Style" service support.</P></content></DIV>
<H2 class=heading>Client</H2>
<DIV id=sectionSection2 class=section><content 
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
<P xmlns="">The client calls the syndication service and writes the feed 
contents to the console. The program first prompts for the service namespace to which to connect:</P>
<DIV class=code xmlns=""><SPAN codeLanguage="CSharp">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TH>C#&nbsp;</TH>
</TR>
  <TR>
    <TD colSpan=2><PRE>static void Main(string[] args)
{
      Console.Write("Enter the name of the Service Namespace you want to connect to: ");
      string serviceNamespace = Console.ReadLine();</PRE></TD></TR></TBODY></TABLE></SPAN></DIV>
<P xmlns="">The client then transmits a request to the URI of the service.</P>
<DIV class=code xmlns=""><SPAN codeLanguage="CSharp">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TH>C#&nbsp;</TH>
</TR>
  <TR>
    <TD colSpan=2><PRE>     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceUri.ToString());
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

    Stream stream = response.GetResponseStream();
    XmlReader reader = XmlReader.Create(stream);
    Rss20FeedFormatter formatter = new Rss20FeedFormatter();
    formatter.ReadFrom(reader);

    Console.WriteLine("\nThese are the contents of your feed: ");
    Console.WriteLine(" ");
    Console.WriteLine(formatter.Feed.Title.Text);
    foreach (SyndicationItem item in formatter.Feed.Items)
    {
        Console.WriteLine(item.Title.Text + ": " + item.Summary.Text);
    }</PRE></TD></TR></TBODY></TABLE></SPAN></DIV>
<P xmlns="">In the service configuration file, the 
<CODE>relayClientAuthenticationType</CODE> setting controls whether or not a client 
is required to authenticate when accessing the HTTP service. The setting in this example is 
<B>None</B>, which means that access is granted to anyone. </P>
<DIV class=code xmlns=""><SPAN codeLanguage="xml">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TH>Xml&nbsp;</TH>
</TR>
  <TR>
    <TD colSpan=2><PRE>&lt;webHttpRelayBinding&gt;
  &lt;binding name="default"&gt;
    &lt;security relayClientAuthenticationType="None" /&gt;
  &lt;/binding&gt;
&lt;/webHttpRelayBinding&gt;</PRE></TD></TR></TBODY></TABLE></SPAN></DIV></content></DIV>
<H2 class=heading>Building and Running the Sample</H2>
<DIV id=sectionSection3 class=section><content 
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
<P xmlns="">First, build the solution in Visual Studio or from the command line. To 
    run the application, do the following:</P>
<OL class=ordered xmlns="">
  <LI>From a command prompt, run the service (Service\bin\Debug\Service.exe).<BR><BR>
  <LI>When prompted, type the service namespace, the issuer name (e.g. &quot;owner&quot;) and 
      the issuer secret key with which you want the service to run. When 
      authorized, the service indicates that it is listening at the configured 
      address.<BR><BR>
  <LI>From another command prompt, run the client (Client\bin\Debug\Client.exe).<BR><BR>
  <LI>When prompted, type the issuer name (e.g. &quot;owner&quot;), the issuer secret key and the service namespace with which you want the client to 
      connect. Enter a line of text to send to the service, then press <B>Enter</B>.<BR><BR>
  <LI>When finished, press <B>Enter</B> to exit the client and the service.<BR><BR></LI></OL>
<DIV class=alert xmlns="">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TH align=left>Note: </TH></TR>
  <TR>
    <TD>You can also point the Web browser to the HTTP URI given below to view the 
      feed contents.
      </TD></TR></TBODY></TABLE>
<P></P></DIV>
<P xmlns=""><B>Expected Output – Service</B></P>
<DIV class=code xmlns=""><SPAN codeLanguage="other">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>

  <TR>
    <TD colSpan=2><PRE>Your Service Namespace: &lt;service-namespace&gt;
Your Issuer Name: owner
Your Issuer Secret: &lt;issuer-secret&gt;    
Service address: http://&lt;service-namespace&gt;.servicebus.windows.net/services/SyndicationService/
Press [Enter] to exit</PRE></TD></TR></TBODY></TABLE></SPAN></DIV>
<P xmlns=""><B>Expected Output – Client</B></P>
<DIV class=code xmlns=""><SPAN codeLanguage="other">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>

  <TR>
    <TD colSpan=2><PRE>Enter the name of the Service Namespace you want to connect to: &lt;service-namespace&gt;
 
These are the contents of your feed:
 
Microsoft Windows Azure Feed
Day 1: Today I woke up and went to work. It was fun.
Day 2: Today I was sick. I didn't go to work. Instead I stayed home and wrote code all day.
Day 3: This is my third entry. Using Microsoft Windows Azure is pretty cool!
Press [Enter] to exit</PRE></TD></TR></TBODY></TABLE></SPAN></DIV></content></DIV><!--[if gte IE 5]><tool:tip 
avoidmouse="false" element="languageFilterToolTip"></tool:tip><![endif]--></DIV>
<P xmlns="">
    <hr /> 
    Did you find this information useful?
    <a href="http://go.microsoft.com/fwlink/?LinkID=155664">
        Please send your suggestions and comments about the documentation.

    </a></P>
</DIV></BODY></HTML>
